package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.SaleList;
import com.atguigu.jxc.entity.SaleListGoods;
import com.atguigu.jxc.service.SaleListGoodsService;
import com.atguigu.jxc.service.SaleListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/saleListGoods")
public class SaleListGoodsController {

    @Autowired
    SaleListGoodsService saleListGoodsService;

    @Autowired
    private SaleListService saleListService;

    @PostMapping("/save")
    public ServiceVO SaveSaleListGoods (SaleList saleList, String saleListGoodsStr){
        ServiceVO serviceVO = saleListGoodsService.saveSaleListGoods(saleList,saleListGoodsStr);
        return serviceVO;
    }
    //请求URL：http://localhost:8080/saleListGoods/updateState
    @PostMapping("/updateState")
    public ServiceVO updateState(Integer saleListId) {
        saleListService.updateState(saleListId);
        return new ServiceVO(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS);
    }

    @PostMapping("count")
    public String count(String sTime, String eTime, Integer goodsTypeId, String codeOrName) {
        return saleListGoodsService.count(sTime, eTime, goodsTypeId, codeOrName);
    }
}